<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://paycn.com.cn/pos" prefix="p"%>

<div class="container-fluid" >
	<div class="row-fluid">
		<div class="span12">
			<h3 class="page-title">角色管理</h3>
			<ul class="breadcrumb">
				<li>
					<i class="icon-home"></i>
					<a href="<c:url value="/home.html"/>">首页</a>
					<i class="icon-angle-right"></i>
				</li>
				<li><a href="#">角色管理</a></li>
			</ul>
		</div>
	</div>
	<div class="row-fluid" >
		<div class="span12">
			<c:choose>	
				<c:when test="${messageSuccess != null}">
					<div class="alert alert-success">
						<strong>成功!</strong>${messageSuccess}
					</div>
				</c:when>
				<c:when test="${messageError != null}">
					<div class="alert alert-error">
						<strong>失败!</strong>${messageError}
					</div>
				</c:when>
			</c:choose>
			<div class="portlet">
				<div class="portlet-title">
					<div class="caption"><i class="icon-search"></i>查询</div>
					<div class="tools">
						<a class="collapse" href="javascript:;"></a>
					</div>
				</div>
				<div class="portlet-body" >
					<form class="form-inline" action="<c:url value="/role/query.html"/>">
						<div class="row-fluid">
							<div class="span2 query">
								<div class="control-group">
									<label class="control-label">角色名称</label>
									<div class="controls">
										<input type="text" name="name" class="span12 m-wrap" value="${param['name']}"/>
									</div>
								</div>
							</div>
							<div class="span2 query">
								<div class="control-group">
									<label class="control-label">&nbsp;</label>
									<div class="controls">
										<button type="submit" class="btn blue purple-stripe"><i class="icon-search"></i>查询</button>
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>	
	<div class="row-fluid">	
		<div class="span12">
			<div class="portlet box grey">
				<div class="portlet-title">
					<div class="caption"><i class="icon-bookmark"></i>用户</div>
				</div>
				<div class="portlet-body no-more-tables">
					<table class="table  table-bordered table-striped table-hover">
						<thead>
							<tr>
								<th>名称</th>
								<th>操作员</th>
								<th>创建日期</th>
								<th>操作</th>	
							</tr>
						</thead>
						<tbody>
							<c:forEach var="role" items="${datagrid.rows}">
								<tr>
									<td data-title="名称">${role.name}</td>
									<td data-title="操作员">${role.createdBy}</td>
									<td data-title="创建日期"><fmt:formatDate value="${role.createdDate }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
									<td data-title="操作">
										<a href="<c:url value="/role/${role.id}/edit.html"/>" class="btn mini blue"><i class="icon-edit"></i> 修改</a>
										<a href="<c:url value="/role/${role.id}/permission.html"/>" class="btn mini purple"><i class="icon-tags"></i> 权限</a>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					<p:pagination url="/role/query.html" total="${datagrid.total }"/>
				</div>
			</div>
		</div>
	</div>
</div>

<div id='role-remove' class='modal hide fade' tabindex='-1' 
	data-backdrop='static' data-keyboard='false'>
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal"></button>
		<h4>删除角色</h4>
	</div>
	<div class='modal-body'>
		<h5>是否删除角色？</h5>
		<form method="post" id="role-remove-form"></form>
	</div>
	<div class='modal-footer'>
		<button type='button' class='btn green ensure'>确定</button>
		<button type='button' data-dismiss='modal' class='btn'>取消</button>
	</div>
</div>
<script type="text/javascript">
	function remote_confirm(evn){
		evn.preventDefault();
		evn.stopPropagation();
		
		$("#role-remove").on("hidden", function(){
			$(this).find("form").removeAttr("action");
		});
		
		var url = $(this).attr("href");
		$("#role-remove-form").attr("action", url);
		$("#role-remove").modal("show");
	}
	function role_delete_submit(){
		$("#role-remove-form").submit();
	}
	$(function(){
		$(".remote-confirm").bind("click",remote_confirm);
		$("#role-remove .ensure").bind("click",role_delete_submit);
	});
</script>